﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Text.RegularExpressions;

public partial class caseindex1 : System.Web.UI.Page 
{ 
   
	protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {

            //工作动态
			Socut.Reader sdrzbindexa = new Socut.Reader("select top 10 id,title,addtime from web_notice where smallclassid=29 order by addtime desc,id desc ");
			zbindexa.InnerHtml += "<table width='98%' border='0' align='center' cellpadding='0' cellspacing='0' class='graylink'>";
			while (sdrzbindexa.Read())
			{
			zbindexa.InnerHtml += "<tr><td height='22'><img src='images/arrowgrey-r.gif' align='absmiddle'>&nbsp;<a href='caseview.aspx?ID=" + sdrzbindexa["id"].ToString() + "' target='_blank' title='" + sdrzbindexa["title"].ToString() + "'>" + CutString(sdrzbindexa["title"].ToString(), 50) + "</a></td><td align=left><font color='666666' style='font-size:12px;'>[" + DateTime.Parse(sdrzbindexa["addtime"].ToString()).ToShortDateString() + "]</font></td></tr>";
			}
			zbindexa.InnerHtml += "</table>";
			sdrzbindexa.Close();
			
        }
        
    }


    static bool IsNumeric(string str)
    {
        if (str == null || str.Length == 0)
            return false;
        foreach (char c in str)
        {
            if (!Char.IsNumber(c))
            {
                return false;
            }
        }
        return true;
    }
	
	public string checkstatus(string str)
	{
		string strstatus="";
		if (str=="0")
		{
			strstatus="未结案";
		}
		else if (str=="1")
		{
			strstatus="已结案";
		}
		else if (str=="2")
		{
			strstatus="已流转";
		}
		return strstatus;
	}

    /// <summary>
    /// 去除HTML标签
    /// </summary>
    /// <param name="RContent">要去除标签的文本</param>
    /// <returns></returns>
    public string Clear_HTML_Code(string RContent)
    {
        int index1 = RContent.IndexOf("<STYLE>");
        if (index1 >= 0)
        {
            int index2 = RContent.LastIndexOf("</STYLE>");
            if (index2 > index1)
            {
               RContent=RContent.Remove(index1, index2 - index1);
            }
        }
        RContent = Regex.Replace(RContent, "<[^>]+>", "");
        
        return RContent;
    }
    public static string getStr(string s, int l)
    {
        string temp = s;
        temp = temp.Replace("<div>", "");
        temp = temp.Replace("&nbsp;", "");
        temp = temp.Replace("</div>", "");
		
        if (Regex.Replace(temp, "[\u4e00-\u9fa5]", "zz", RegexOptions.IgnoreCase).Length <= l)
        {
            return temp;
        }
        for (int i = temp.Length; i >= 0; i--)
        {
            temp = temp.Substring(0, i);
            if (Regex.Replace(temp, "[\u4e00-\u9fa5]", "zz", RegexOptions.IgnoreCase).Length <= l - 3)
            {
                return temp + "";
            }
        }
        return "";
    }

public string CutString(string str,int length)
        {
            int i = 0, j = 0;
            foreach(char chr in str)
            {
                if((int)chr > 127)
                {
                    i += 2;
                }
                else
                {
                    i ++;
                }
                if (i > length)
                {
                    str = str.Substring(0, j) + "..";
                    break;
                }
                j ++;
            }
            return str;
        } 
    public string htmlstr(string chr)
    {
        if (chr == null)
            return "";
        //chr = chr.Replace("<", "&lt");
        //chr = chr.Replace(">", "&gt");
        chr = chr.Replace("\n", "<br>");
        //chr = chr.Replace("\"", "&quot;");
        //chr = chr.Replace("'", "&#39;");
        chr = chr.Replace(" ", "&nbsp;");
        chr = chr.Replace("select", "");
        chr = chr.Replace("delete", "");
        chr = chr.Replace("update", "");
        chr = chr.Replace("drop", "");
        //chr = chr.Replace(";", "");
        //chr = chr.Replace("(", "");
        //chr = chr.Replace(")", "");
        chr = chr.Replace("and", "");
        chr = chr.Replace("or", "");
        //chr = chr.Replace("\r", "");
        return (chr);
    }

}
